package com.light.gamecomponents.gravitylight;

import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.region.TextureRegion;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.light.gamecomponents.IGameComponents;
import com.light.gamecomponents.physics.PhysicsComponents;
import com.light.mapcomponents.PanelComponents;
import com.light.roller.ResourceManager;
import com.light.roller.Roller;

public abstract class GravityLight implements IGameComponents{
	
	protected String m_resourceName;
	protected TextureRegion m_textureRegion;
	protected Roller m_game;
	protected Sprite m_sprite;
	protected Body m_body;
	protected float m_initialPositionX, m_initialPositionY;
	protected float m_sizeX, m_sizeY;
	
	public Body getCollisionShape() { return m_body; }
	public Vector2 getSpritePosition() 
	{ 
		return new Vector2(m_sprite.getX() + m_sprite.getBaseWidth() / 2,
				           m_sprite.getY() + m_sprite.getBaseHeight() / 2); 
	}
	public void setPosition(float x, float y) { m_sprite.setPosition(x, y); }
	
	public GravityLight(Roller game, String resourceName, float x, float y, float sizeX, float sizeY)
	{
		this.m_game = game;
		this.m_resourceName = resourceName;
		this.m_initialPositionX = x;
		this.m_initialPositionY = y;
		this.m_sizeX = x;
		this.m_sizeY = y;
	}
	@Override
	public void onLoadResources()
	{
		ResourceManager.onLoadResources(m_resourceName, m_game);
		m_textureRegion = ResourceManager.getTextureRegion(m_resourceName);
	}
	
	@Override
	public void unLoadResources() {
		m_textureRegion = null;
		ResourceManager.unLoadResources(m_resourceName, m_game);
	}
	
	public float getWidth() { return m_sprite.getWidth(); }
	public float getHeight() { return m_sprite.getHeight(); }
	public abstract boolean collidesWith(PhysicsComponents PC);
	public abstract boolean collidesWith(PanelComponents PC);


	
}
